package com.wuliu.business.sys;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.wuliu.model.sys.UserBank;
import com.wuliu.util.DbPool;

public class UserBankObj {
	public static UserBank getUserBankById(String id){
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		UserBank userBank = new UserBank();
		if(id==null || id.equals(""))
			return userBank;
		String strsql = "SELECT * FROM WL_USER_BANK WHERE KEY_ID=?";
		try{
			conn = DbPool.getConnection();
			pstmt = conn.prepareStatement(strsql);
			pstmt.setString(1,id);
			rs = pstmt.executeQuery();
			if(rs.next()){
				userBank.setKeyId(rs.getString("KEY_ID"));
				userBank.setUserAccount(rs.getString("USER_ACCOUNT"));
				userBank.setBankCode(rs.getString("BANK_CODE"));
				userBank.setCardType(rs.getString("CARD_TYPE"));
				userBank.setCardNo(rs.getString("CARD_NO"));
				userBank.setTelNo(rs.getString("TEL_NO"));
				userBank.setCheckCode(rs.getString("CHECK_CODE"));
				userBank.setValidDate(rs.getString("VALID_DATE"));
			}
		}catch(SQLException sqlE){
			sqlE.printStackTrace();
		}finally{
			DbPool.close(conn, pstmt, rs);
		}
		return userBank;
	}
}
